<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn" xml:lang="zh-cn">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="DC.Type" content="topic">
  <meta name="DC.Title" content="步骤1：检查并开启PostgreSQL数据库安装用户sudo权限">
  <meta name="product" content="">
  <meta name="DC.Relation" scheme="URI" content="postgresql-0009.html">
  <meta name="prodname" content="">
  <meta name="version" content="">
  <meta name="brand" content="">
  <meta name="DC.Publisher" content="20250306">
  <meta name="prodname" content="csbs">
  <meta name="documenttype" content="usermanual">
  <meta name="DC.Format" content="XHTML">
  <meta name="DC.Identifier" content="postgresql-0080">
  <meta name="DC.Language" content="zh-cn">
  <link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
  <title>步骤1：检查并开启PostgreSQL数据库安装用户sudo权限</title>
 </head>
 <body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px">
  <a name="postgresql-0080"></a><a name="postgresql-0080"></a>
  <h1 class="topictitle1">步骤1：检查并开启PostgreSQL数据库安装用户sudo权限</h1>
  <div>
   <p>在执行数据库备份前需要检查并开启数据库安装用户sudo权限，否则将会导致部分命令执行失败。仅集群场景下需要执行本章节操作。</p>
   <div class="section">
    <h4 class="sectiontitle">操作步骤</h4>
    <ol>
     <li><span>使用PuTTY，登录PostgreSQL数据库主机。</span></li>
     <li><span>执行以下命令查看用户是否有sudo权限。</span><p></p><pre class="screen">sudo -l -U <em>数据库安装用户</em></pre>
      <ul>
       <li>如果该用户具有sudo权限，则会显示用户可以运行的命令列表，操作结束。<p><span><img src="zh-cn_image_0000002164763694.png"></span></p></li>
       <li>如果该用户没有sudo权限，则会显示一条消息，指出该用户不能执行sudo命令，请继续执行<a href="#postgresql-0080__li89912406816">3</a>。<p><span><img src="zh-cn_image_0000002200004701.png"></span></p></li>
      </ul> <p></p></li>
     <li id="postgresql-0080__li89912406816"><a name="postgresql-0080__li89912406816"></a><a name="li89912406816"></a><span>开启数据库安装用户sudo权限。</span><p></p><p>切换到root用户，执行<strong>visudo</strong>命令，进入配置文件，在文件末尾添加如下配置：</p> <p><em>数据库安装用户名</em> ALL=(ALL) NOPASSWD:ALL</p> <p></p></li>
    </ol>
   </div>
  </div>
  <div>
   <div class="familylinks">
    <div class="parentlink">
     <strong>父主题：</strong> <a href="postgresql-0009.html">备份PostgreSQL</a>
    </div>
   </div>
  </div>
 </body>
</html>